package org.mat.ipaas.ucenter.service.api.system;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.mat.framework.lang.dto.MatApiResponse;
import org.mat.ipaas.ucenter.service.dto.system.entity.SysDepartRoleDTO;
import org.mat.ipaas.ucenter.service.dto.system.entity.SysDepartRoleUserDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 部门角色
 */
@Api(tags = "部门角色")
@FeignClient(name = "mat-ipaas-ucenter-service", contextId = "sys-depart-role-rest-api")
public interface SysDepartRoleRestAPI {


    /**
     * 分页列表查询
     *
     * @param sysDepartRoleDTO
     * @param pageNo
     * @param pageSize
     * @return
     */
    @ApiOperation(value = "部门角色-分页列表查询", notes = "部门角色-分页列表查询")
    @GetMapping(value = "/sys/sysDepartRole/list")
    MatApiResponse<?> queryPageList(@SpringQueryMap SysDepartRoleDTO sysDepartRoleDTO,
                                    @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                    @RequestParam(name = "deptId", required = false) String deptId);

    /**
     * 添加
     *
     * @param sysDepartRoleDTO
     * @return
     */
    //@RequiresPermissions("system:depart:role:add")
    @ApiOperation(value = "部门角色-添加", notes = "部门角色-添加")
    @PostMapping(value = "/sys/sysDepartRole/add")
    MatApiResponse<?> add(@RequestBody SysDepartRoleDTO sysDepartRoleDTO);

    /**
     * 编辑
     *
     * @param sysDepartRoleDTO
     * @return
     */
    @ApiOperation(value = "部门角色-编辑", notes = "部门角色-编辑")
    //@RequiresPermissions("system:depart:role:edit")
    @RequestMapping(value = "/sys/sysDepartRole/edit", method = {RequestMethod.POST})
    MatApiResponse<?> edit(@RequestBody SysDepartRoleDTO sysDepartRoleDTO);

    /**
     * 通过id删除
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "部门角色-通过id删除", notes = "部门角色-通过id删除")
    //@RequiresPermissions("system:depart:role:delete")
    @DeleteMapping(value = "/sys/sysDepartRole/delete")
    MatApiResponse<?> delete(@RequestParam(name = "id", required = true) String id);

    /**
     * 批量删除
     *
     * @param ids
     * @return
     */
    @ApiOperation(value = "部门角色-批量删除", notes = "部门角色-批量删除")
    //@RequiresPermissions("system:depart:role:deleteBatch")
    @DeleteMapping(value = "/sys/sysDepartRole/deleteBatch")
    MatApiResponse<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids);

    /**
     * 通过id查询
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "部门角色-通过id查询", notes = "部门角色-通过id查询")
    @GetMapping(value = "/sys/sysDepartRole/queryById")
    MatApiResponse<?> queryById(@RequestParam(name = "id", required = true) String id);

    /**
     * 获取部门下角色
     *
     * @param departId
     * @return
     */
    @RequestMapping(value = "/sys/sysDepartRole/getDeptRoleList", method = RequestMethod.GET)
    MatApiResponse<List<SysDepartRoleDTO>> getDeptRoleList(@RequestParam(value = "departId") String departId, @RequestParam(value = "userId") String userId);

    /**
     * 设置
     *
     * @param json
     * @return
     */
    //@RequiresPermissions("system:depart:role:userAdd")
    @RequestMapping(value = "/sys/sysDepartRole/deptRoleUserAdd", method = RequestMethod.POST)
    MatApiResponse<?> deptRoleAdd(@RequestBody JSONObject json);

    /**
     * 根据用户id获取已设置部门角色
     *
     * @param userId
     * @return
     */
    @RequestMapping(value = "/sys/sysDepartRole/getDeptRoleByUserId", method = RequestMethod.GET)
    MatApiResponse<List<SysDepartRoleUserDTO>> getDeptRoleByUserId(@RequestParam(value = "userId") String userId, @RequestParam(value = "departId") String departId);

    /**
     * 查询数据规则数据
     */
    @GetMapping(value = "/sys/sysDepartRole/datarule/{permissionId}/{departId}/{roleId}")
    MatApiResponse<?> loadDatarule(@PathVariable("permissionId") String permissionId, @PathVariable("departId") String departId, @PathVariable("roleId") String roleId);

    /**
     * 保存数据规则至角色菜单关联表
     */
    @PostMapping(value = "/sys/sysDepartRole/datarule")
    MatApiResponse<?> saveDatarule(@RequestBody JSONObject jsonObject);

    /**
     * 导出excel
     *
     * @param sysDepartRoleDTO
     */
    @RequestMapping(value = "/sys/sysDepartRole/exportXls")
    ModelAndView exportXls(SysDepartRoleDTO sysDepartRoleDTO);

    /**
     * 通过excel导入数据
     *
     * @return
     */
    @RequestMapping(value = "/sys/sysDepartRole/importExcel", method = RequestMethod.POST)
    MatApiResponse<?> importExcel();

}
